package lab03.test09;

import java.io.*;
import java.util.ArrayList;

/**
 * Created by dell on 2017/12/29.
 */
public class Booklist {
    ArrayList<Book> book = new ArrayList<Book>();

    void readerAndWrite() {
        FileReader in = null;
        try {
            in = new FileReader("E\\java123\\pbookinfo.txt");
            BufferedReader reader = new BufferedReader(in);
            FileWriter out = new FileWriter("E\\java123\\book\\pbookinfonew.txt");
            BufferedWriter writer = new BufferedWriter(out);
            String string = reader.readLine();
            writer.write(string + "\r\n");
            while ((string = reader.readLine()) != null) {
                String str[] = string.split("\\s{2,}");
                book.add(new Book(str[0], str[1], str[2], str[3], str[4]));
            }
            book.get(2).increasePrice(20);
            book.get(3).increasePrice(30);
            for (int i = 0; i < book.size(); i++) {
                writer.write(book.get(i).toString());
            }
            reader.close();
            writer.close();
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    }